﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace job
{
    public partial class admin2_xiugai : Form
    {
        string ID = "";
        public admin2_xiugai()
        {
            InitializeComponent();
        }
        public admin2_xiugai(string sno, string name, string Smajor, string Snumber, string Sgoto) //id可改为sno  前面的删除里面的id也要改
        {
            InitializeComponent();
            ID = textBox1sno.Text = sno;
          //  textBox1sno.Text = sno;//作为主键要写一个公共变量在前面调用
            textBox2name.Text = name;
            textBox3major.Text = Smajor;
            textBox4number.Text = Snumber;
            textBox5goto.Text = Sgoto;

        }
        private void button1_Click(object sender, EventArgs e)
        {
            string sql = $"update student_news set sno='{textBox1sno.Text}',name='{textBox2name.Text }',Smajor='{textBox3major.Text }',Snumber='{textBox4number.Text }',Sgoto='{textBox5goto.Text }' where sno='{ID}'";//WHERE 后面是id  因为是前面定义的全局变量，
             Dao dao = new Dao(); 
            int n = dao.Execute(sql);
            if (n > 0)
            {
                MessageBox.Show("修改成功");
                this.Close();
            }
        }
    }
}
